<!-- 图片列表-图片列表 -->
<template>
    <el-collapse modelValue="1">
        <el-collapse-item title="图片列表" name="1">
            <si-collapse-group
                v-model="list"
                is-draggable
                is-add
                is-delete
                add-text="添加图片"
                :add="getAddData"
                :node-title="data => data.title"
            >
                <template #item="{ element, index }">
                    <div class="row-wrap">
                        <div class="left-wrap">
                            标题
                        </div>
                        <div class="right-wrap">
                            <el-input v-model="element.title" placeholder="请输入标题" />
                        </div>
                    </div>

                    <el-divider></el-divider>
                    <div class="row-wrap">
                        <div class="left-wrap">
                            图片
                        </div>
                        <div class="right-wrap">
                            <si-image-picker
                                v-model="element.pic"
                                type="image"
                                :show-label="false"
                                :size="100"
                            />
                        </div>
                    </div>

                    <el-divider></el-divider>
                    <si-click-event v-model:event="element.customFeature" />
                </template>
            </si-collapse-group>
        </el-collapse-item>
    </el-collapse>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
import {
    SiClickEvent,
    SiImagePicker,
    SiCollapseGroup
} from '@/components/setting-pane/setting-item'
export default defineComponent({
    name: 'AlbumContent',
    components: {
        SiClickEvent,
        SiImagePicker,
        SiCollapseGroup
    },
    props: {
        widget: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props) {
        const { widget } = toRefs(props)

        const list = computed({
            get: () => widget.value.widgetData.eles.content || [],
            set: val => widget.value.widgetData.eles.content = val
        })

        const getAddData = () => {
            return {
                title: '标题',
                pic: '',
                customFeature: {
                    action: ''
                }
            }
        }

        return {
            widget,
            list,
            getAddData
        }
    }
})
</script>

<style lang="less" scoped>
.row-wrap {
    display: flex;
    align-items: center;
    .left-wrap {
        margin-right: 10px;
    }
    .right-wrap {
        // 
    }
}
</style>